package kr.or.kead.ui.departmgn;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import kr.or.kead.domain.Depart;
import kr.or.kead.domain.InfoStudent;
import kr.or.kead.service.DaoInfoStudent;
import kr.or.kead.service.DaoTable;
import kr.or.kead.service.Daodepart;

public class CustomTableModel extends AbstractTableModel {
	private ArrayList<Object> departs;
	
	//테이블 각 열에 대한 이름
	private static final String[] columnNames=
		{"번호","학과명","지도교수","연락처"};
	//테이블 각 열에 대한 클래스
	private static final Class[] columnClass=
		{Integer.class, String.class, Integer.class,String.class};
	
	public CustomTableModel() {
		DaoTable dao = new Daodepart();
		departs = dao.selectDao();
	}
	@Override
	public int getColumnCount() {
		return columnNames.length;
	}
	@Override
	public int getRowCount() {
		return departs.size();
	}
	@Override
	public Class<?> getColumnClass(int col) {
		return columnClass[col];
	}
	@Override
	public String getColumnName(int column) {
		return columnNames[column];
	}
	@Override
	public Object getValueAt(int row, int col) {
		Depart depart = (Depart)departs.get(row);
		switch(col){
		case 0: return depart.getCode();
		case 1: return depart.getName();
		case 2: return depart.getProt();
		case 3: return depart.getTel();
		}
		return "";
	}

}





